package com.kitty.game.fight.bean;

import com.kitty.game.boss.config.BossSet;
import com.kitty.game.boss.model.BossParam;
import com.kitty.game.enter.FiedValue;
import com.kitty.game.fight.ai.NormalSkillChooser;
import com.kitty.game.fight.ai.SkillChooser;
import com.kitty.game.fight.bean.FightObject;
import com.kitty.game.fight.message.vo.FightMember;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

@Getter
@Setter
public class BossFightObject extends FightObject {
    private static List<String> showLifeBossNames = Arrays.asList("九幽大帝","大日金乌","真武大帝","邪灵大帝","杀戮大帝","魔龙吞天","魔龙之爪","魔龙之首","魔龙之眼","二星魔龙吞天","二星魔龙之爪","二星魔龙之首","二星魔龙之眼",
            "魔龙之尾","炼狱冥炎","二星炼狱冥炎","昊天君","阳天君","赤天君","朱天君","成天君","幽天君","玄天君","变天君","钧天君","二星魔龙之尾");
    private BossParam bossParam;

    private SkillChooser skillChooser = new NormalSkillChooser();

    public BossFightObject(BossSet bossSet, BossParam bossParam, Short pos, int monsterId, short level) {
        double randomLife = 1 + (new Random().nextInt(30) + 10) / 100.00;
        this.bossParam=bossParam;
        setPos(pos);
        setName(bossParam.getName());
        setLevel(level);
        setId(monsterId);
        setDefense(bossSet.getFangyu() * level);
        setSpeed( (bossSet.getSudu() * level));
        setMagPower(bossSet.getFagong() * level);
        setPhyPower(bossSet.getWugong() * level);
        setMaxLife((int) (bossParam.getLife() > 0 ? bossParam.getLife() : (bossSet.getQixue() * level*randomLife)));
        setCurrLife((int) (bossParam.getLife() > 0 ? bossParam.getLife() : (bossSet.getQixue() * level*randomLife)));
        setPolar(bossParam.getPolar());
        setSkillIds(bossParam.getSkillIds());
        setIcon(bossParam.getIcon());
        setBossSet(bossSet);
        setWeaponId(bossParam.getWeaponIcon());
        setSuitIcon(bossParam.getSuitIcon());

        skillChooser.init(getSkillIds());
    }

    @Override
    public FightMember asFightMember() {
        FightMember fightMember = new FightMember();
        fightMember.setId(getId());
        fightMember.setPosition((short) getPos());
        fightMember.setIcon((short) getIcon());
        fightMember.setWeapon_icon((short) getWeaponId());
        fightMember.setList(asFieldValues());
        if(bossParam!=null){
            fightMember.setSuit_light_effect(bossParam.getSuitLightEffect());
            fightMember.setSuit_icon(bossParam.getSuitIcon());
        }
        fightMember.setId(getId());
        return fightMember;
    }

    @Override
    public List<FiedValue> asFieldValues() {
        ArrayList<FiedValue> fiedValues = new ArrayList<>();
        if(isShowLife(name)){
            fiedValues.add(new FiedValue(1061, 1, 1));
            fiedValues.add(new FiedValue(1054, 1, 1));
        }
        fiedValues.add(new FiedValue(1, 4, getName()));
        fiedValues.add(new FiedValue(40, 7, getIcon()));
        fiedValues.add(new FiedValue(41, 7, (short) 2));
        fiedValues.add(new FiedValue(204, 3, 0));
        fiedValues.add(new FiedValue(341, 1, (byte) 0));
        fiedValues.add(new FiedValue(340, 1, (byte) 0));
        return fiedValues;
    }

    public SkillChooser getSkillChooser() {
        return skillChooser;
    }

    @Override
    public boolean isMonster() {
        return true;
    }


    @Override
    public int getPhyHurt(FightObject target, boolean isPenetrate) {
        return super.getPhyHurt(target, isPenetrate);
    }

    @Override
    public int getTao(){
       return getBossSet().getDaohang();
    }
    @Override
    public String toString() {
        return "BossFightObject{" +
                "id=" + id +
                '}';
    }
    public boolean isShowLife(String name){
        boolean contains = showLifeBossNames.contains(name);
        return contains;
    }

    public static void main(String[] args) {
        System.out.println();
    }
}
